﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WindowsFormsApp1
{
    class DbHelsper
    {
        private static readonly string conString = "server =.;database=Blogs;uid=sa ;pwd=nbzdwan20;";
        public static DataTable GetDateTable(string sql)
        {
            SqlConnection sqlConnection = new SqlConnection(conString);
            
            SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sql, sqlConnection);
            DataTable dt = new DataTable();
            sqlConnection.Open();
            sqlDataAdapter.Fill(dt);
            return dt;


        }
        public static DataSet dataSet(string SQL)
        {
            SqlConnection sqlConnection = new SqlConnection(conString);

            SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(SQL, sqlConnection);
            DataSet at  = new  DataSet();
            sqlConnection.Open();
            sqlDataAdapter.Fill(at);
            return at;
        }
        
    }
   
}
